using Engine;
using Engine.Graphics;
using Game;

namespace SCIENEW {
    /// <summary>
    /// 对应原版FlatBlock，平面物品
    /// </summary>
    public class FlatItem : DefaultItem {
        public int DefaultTextureSlot;
        public Color Color = Color.White;
        public float Size = 1f;

        public FlatItem(string id, int textureSlot, float size = 1f) : base(id) {
            DefaultTextureSlot = textureSlot;
            Size = size;
        }

        public FlatItem(string id) : base(id){}

        public override int GetFaceTextureSlot(int face, int value) => DefaultTextureSlot;

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) {
            BlocksManager.DrawFlatBlock(primitivesRenderer, value, size * Size, ref matrix, GetTexture(), Color * color, false, environmentData);
        }

        public override Vector3 GetIconViewOffset(int value, DrawBlockEnvironmentData environmentData) => new Vector3 { Z = 1 };

        public virtual Texture2D GetTexture() => IndustrialModLoader.BaseTexture;
    }
}